<template>
	<view class="page">
		<view class="content">
			<mescroll-uni refs="mescroll" @getData="getData">
				<block slot="list">
					<block v-if="dataList.length">
						<view class="content-item" v-for="(item,index) in dataList" :key="index">
							<view class="item-title">
								<image class="head-img" :src="item.headimg ? $util.img(item.headimg) : $util.getDefaultImage().default_headimg"></image>
								<!-- <image class="head-img" src="../../../static/add.png" mode=""></image> -->
								<view class="item-title-info">
									<text class="item-name">
										{{item.username}}
									</text>
									<text class="item-time">{{$util.timeStampTurnTime(item.reg_time).toString().substring(0,11)}}成为下级</text>
								</view>
							</view>
							<view class="item-content">
								<view class="item-content-item">
									<text class="item-count">订单数量(个)</text>
									<text>{{item.order_num}}</text>
								</view>
								<view class="item-content-item">
									<text class="item-count">获利总额(元)</text>
									<text>{{item.commission_money}}</text>
								</view>
								<view class="item-content-item">
									<text class="item-count">返佣总额(元)</text>
									<text>{{item.superior_commission_money}}</text>
								</view>
							</view>
						</view>
					</block>
					<block v-else>
						<ns-empty text="暂无数据" :isIndex="!1"></ns-empty>
					</block>
				</block>
			</mescroll-uni>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataList: [],
				jiaData: [{
					"member_id": 82,
					"username": "pintuan_003",
					"nickname": "拼团商3",
					"pintuan_trader_level": "common",
					"pintuan_trader_level_name": "普通拼团商",
					"reg_time": 1608792676,
					"pintuan_trader_order_num": 0,
					"pintuan_trader_commission_money": "0.00",
					"pintuan_trader_source_agent_commission_money": "0.00"
				}, {
					"member_id": 81,
					"username": "pintuan_002",
					"nickname": "拼团商2",
					"pintuan_trader_level": "common",
					"pintuan_trader_level_name": "普通拼团商",
					"reg_time": 1608792649,
					"pintuan_trader_order_num": 0,
					"pintuan_trader_commission_money": "0.00",
					"pintuan_trader_source_agent_commission_money": "0.00"
				}, {
					"member_id": 80,
					"username": "pintuan_001",
					"nickname": "拼团商1",
					"pintuan_trader_level": "common",
					"pintuan_trader_level_name": "普通拼团商",
					"reg_time": 1608792623,
					"pintuan_trader_order_num": 0,
					"pintuan_trader_commission_money": "0.00",
					"pintuan_trader_source_agent_commission_money": "0.00"
				}],
				mescroll: null
			};
		},
		onShow() {

		},
		onLoad(option) {

		},
		methods: {
			getData(mescroll) {
				this.mescroll = mescroll;
				this.$api.sendRequest({
					url: '/platformpintuan/api/Pintuantrader/agentChildList',
					data: {
						page_size: mescroll.size,
						page: mescroll.num
					},
					success: res => {
						let newArr = []
					
						let msg = res.message;
						if (res.code == 0 && res.data) {
							newArr = res.data.list;
						} else {
							this.$util.showToast({
								title: msg
							})
						}
						mescroll.endSuccess(newArr.length);
						//设置列表数据
						if (mescroll.num == 1) this.dataList = []; //如果是第一页需手动制空列表
						this.dataList = this.dataList.concat(newArr); //追加新数据
						if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
					},
					fail: res => {
						mescroll.endErr();
						if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	.page {
		width: 100%;
		height: 100vh;
		background-color: #eee;

		.content {
			box-sizing: border-box;
			width: 80%;
			margin: 0 auto;
			border-radius: 20rpx;


			.content-item {
				background-color: #ffffff;
				border-radius: 15rpx;
				//width: 0%;
				//border-radius: 20rpx;
				margin: 30rpx 20rpx;
				overflow: hidden;

				.item-title {
					display: flex;
					box-sizing: border-box;
					width: 100%;
					padding: 20rpx 20rpx;
					border-bottom: 1px solid #ccc;

					.item-title-info {
						margin-left: 10rpx;
						display: flex;
						flex-direction: column;
						justify-content: center;

						.item-name {
							color: #4C494A;
							font-size: 34rpx;
						}

						.item-time {
							font-size: 28rpx;
							color: #909399;
						}


					}

					.head-img {
						height: 120rpx;
						width: 120rpx;
						border-radius: 30rpx;
					}

				}

				.item-content {
					display: flex;
					justify-content: space-around;
					padding: 20rpx 0;

					.item-content-item {
						display: flex;
						flex-direction: column;

						.item-count {
							font-size: 30rpx;
							color: #909399;
						}
					}
				}
			}
		}

	}
</style>
